<script setup>
import { getBannerApi } from "@/api/home";
import { ref, onMounted } from "vue";

const bannerList = ref([]);

const getBanner = async () => {
  const res = await getBannerApi();
  bannerList.value = res.result;
};
onMounted(getBanner);
</script>

<template>
  <div class="banner" m="t-4">
    <el-carousel trigger="click" height="500px">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <img :src="item.imgUrl" alt="" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<style lang="scss" scoped>
.banner {
  position: absolute;
  top: 0;
  left: 0;
  width: 1240px;
  height: 500px;
  z-index: 98;

  .el-carousel {
    .el-carousel__item {
      width: 100%;
      height: 100%;
      color: #475669;
      opacity: 0.75;
      line-height: 150px;
      margin: 0;
      text-align: center;
      .el-carousel__item:nth-child(2n) {
        background-color: #99a9bf;
      }

      .el-carousel__item:nth-child(2n + 1) {
        background-color: #d3dce6;
      }
    }
  }
}
</style>
